function [moments,residuals] = Var1_GMM_moments(theta2,VarFactors,Cov10Factors,Cov01Factors,factors)

% We unfold theta2
nx            = size(factors,1);
[h0,hx,sigma] = unfoldTheta2(theta2,nx);
VarW          = sigma*sigma';      
     
% The moments conditions 
T          = size(factors,2);
numTheta2  = length(fieldnames(theta2));
nx         = size(factors,1);
residuals  = zeros(nx,T);
tmp        = zeros(nx,nx,T);
tmp1       = zeros(nx,nx,T);
for t=1:T-1
   residuals(:,t+1) = factors(:,t+1) - (h0 + hx*factors(:,t));
   tmp(:,:,t+1)     = residuals(:,t+1)*factors(:,t)' - Cov10Factors(:,:,t+1) + hx*VarFactors(:,:,t);
   tmp1(:,:,t+1)    = residuals(:,t+1)*residuals(:,t+1)' - VarW - VarFactors(:,:,t) - hx*VarFactors(:,:,t)*hx' ...
       + Cov10Factors(:,:,t+1)*hx' + hx*Cov01Factors(:,:,t+1);
end

% The moment conditions 
moments         = zeros(numTheta2,T-1);
moments(1:nx,:) = residuals(:,2:T);
for t=1:T-1
   moments(nx+1:nx+nx^2,t) = reshape(tmp(:,:,t+1),nx*nx,1);
   moments(nx+nx^2+1:end,t)= vech(tmp1(:,:,t+1));
end

end